


//const obj1 = dispatch('hello');
//console.log(obj1.msg);

const dispatch = require('./build/Release/dispatch');
//////////////////////////////////////////////////////////////////////////
var n = __dirname.lastIndexOf("/");
var std_com_path = __dirname.substring(0,n);
std_com_path += "/libs/"
console.log(std_com_path)
//////////////////////////////////////////////////////////////////////////
var license_json = {
    "component": [ 	
        "{F170A724-AACA-4603-BB1C-0A8EAF1C3322}:asynio:1:4",
        "{ED660EF7-7D0B-4CBE-8D92-D5F225434464}:http:2:4",
        "{C54C9CC0-F448-4A49-A622-0467D02E8EB8}:net:3:4",	
        "{CE065148-7803-45B1-B1D7-874B52B8F5C5}:uibase:5:4",	
        "{201409F6-22F8-48d3-A69F-7935BDDE6BFF}:msgbus:4:4"
    ]   
};

var license_code = JSON.stringify(license_json);
console.log(license_code)
//////////////////////////////////////////////////////////////////////////
dispatch.create();
dispatch.start(std_com_path,license_code);
//////////////////////////////////////////////////////////////////////////


var express = require('express');
var app = new express();

app.get('/',function (req,res) {
    //res.send("hello express");
    res.sendFile(__dirname+"/"+"index.html")
})

app.get('/news',function (req,res) {
    res.send("hello news");
})

//动态路由 http://localhost:8001/newscontent/1243
app.get('/newscontent/:aid',function (req,res) {
    //req.params获取动态路由的传值
    var aid = req.params.aid;  //aid = 1243
    res.send("hello newscontent"+"------"+aid);
    console.log(aid)
})

//获取get传值  http://localhost:8001/product?aid=1234567
app.get('/product',function (req,res) {
    var aid =  req.query.aid;
    res.send("hello product----"+aid);
    console.log(aid)
})

console.log("listen : 127.0.0.1:8001")
app.listen('8001','127.0.0.1');
